;;; Copyright © 2020 Maxime Devos <maxime.devos@student.kuleuven.be>
;;; This file is part of rehash.
;;;
;;; rehash is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; rehash is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with rehash.  If not, see <http://www.gnu.org/licenses/>.

(use-modules (rehash)
             (gnu gnunet configuration)
             (srfi srfi-64))
(define test-config #f)
(define s #f)

(test-begin "test-rehash-smoke")
(set! test-config (load-configuration "testconf.conf"))
(set! s (open-rehash-service test-config))

(define h1 (bytevector->hash HASH_SHA256 #vu8(0 1) 0 2))
(define h2 (bytevector->hash HASH_SHA256 #vu8(2 1) 0 2))

(define s1 (store-hash! s h1 h2
                        #:expiration-time (expt 2 48)
                        #:anonymity-level 0))
(define s2 (store-hash! s h2 h1
                        #:expiration-time 345678
                        #:anonymity-level 0))

;; todo higher anonymity levels
(store-abort! s1)
(define q1 (query! s h1 HASH_SHA3_512
                   #:anonymity-level 0
                   #:options 0
                   #:when-found display))
(store-abort! s2)
(query-abort! q1)

(close-rehash-service s)
(test-end "test-rehash-smoke")
